<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>手机通讯录</title>
    <style>
        ul { width: 300px;}
        li { width: 150px; display: inline-block; list-style-type: none; text-align: center;}
        li img { border-radius: 60px; width: 100%;}
    </style>
</head>
<body>
<h1>通讯录</h1>
<form method="get" action="{% url 'contact:search' %}">
    {% csrf_token %}
    <input type="text" name="name" id="name">
    <input type="submit" value="查询">
</form>

{% if contact_list %}
<ul>
    {% for contact in contact_list %}
    {% load static %}
    <li>
        {% if contact.gender == '男' %}
            <img src="{% static 'images/male.jpeg' %}" alt="gender">
        {% else %}
            <img src="{% static 'images/female.jpeg' %}" alt="gender">
        {% endif %}
        <a href="{% url 'contact:detail' contact.id %}">{{ contact.name }}</a>
    </li>
    {% endfor %}
</ul>
{% else %}
<p>通讯录暂无记录</p>
{% endif %}

<form action="{% url 'contact:add_contact' %}" method="post">
    {% csrf_token %}
    <h4>添加联系人</h4>
    姓名：<input type="text" name="name" placeholder="新联系人姓名"><br>
    性别：<select name="gender" >
        <option value="男">男</option>
        <option value="女">女</option>
    </select><br>
    电话：<input type="tel" name="phone" placeholder="新联系人电话"><br>
    时间：<input type="datetime-local" name="pub_date"><br>
    <input type="submit" value="提交">
</form>
</body>
</html>